package cn.ssj.service.impl;

import cn.ssj.dao.AdminDao;
import cn.ssj.entity.Admin;
import cn.ssj.service.AdminService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.DigestUtils;

import javax.websocket.server.ServerEndpoint;


/**
 * Created by Administrator on 2017/9/1 0001.
 */
@Service
public class AdminServiceImpl implements AdminService {

    private static final Logger LOGGER= LoggerFactory.getLogger(AdminServiceImpl.class);
    @Autowired
    private AdminDao dao;
    public Admin login(String name, String password) {
        if (null==name || null==password){
            return null;
        }
        //将密码进行md5加密
        password= DigestUtils.md5DigestAsHex(password.getBytes());
        LOGGER.debug(password);
        Admin admin=null;
        admin=dao.findAdminByNameAndPassword(name,password);
        return admin;
    }
}
